<?php
    @header("Content-type:text/html;charset=utf-8");
    @include_once("./connect.php");

    if(!(isset($_POST["id"]) && isset($_POST["buyNum"]))){
        $obj = array();
        $obj["status"] = false;
        $obj["msg"] = "请传入参数";
        $json = json_encode($obj);
        exit($json);
    }

    $id = $_POST["id"];
    $buyNum = $_POST["buyNum"];

    $sql = "UPDATE `shopcar` set num = $buyNum where id = $id";

    $result = mysqli_query($conn,$sql);

    $obj = array();
    if($result){
        $rows = mysqli_affected_rows($conn);
        if($rows>0){
            $obj["status"] = true;
            $obj["msg"] = "更新成功";
        }else{
            $obj["status"] = true;
            $obj["msg"] = "更新失败";
        }

    }else{
        $obj["status"] = false;
        $obj["msg"] = "sql语句有误";
        $obj["sql"] = $sql;
    }
    echo json_encode($obj);



?>